package com.zretc.kscxmz.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zretc.kscxmz.entity.Dept;
import com.zretc.kscxmz.mappers.DeptMapper;
import com.zretc.kscxmz.services.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;


    @Override
    public PageInfo<Dept> getCompanyByPage(Map<String, String> param) {
        int pageNum =  Integer.parseInt(param.get("pageNum"));
        int pageSize =  Integer.parseInt(param.get("pageSize"));

        PageHelper.startPage(pageNum,pageSize);

        List<Dept> list = deptMapper.findDeptInfo(param);
        PageInfo<Dept> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int addDeptInfo(Map<String, Object> param) {

        return deptMapper.insertDeptInfo(param);
    }

    @Override
    public int updateDeptInfo(Map<String, Object> param) {

        return deptMapper.updateDeptInfo(param);
    }

    @Override
    public int deleteDeptInfo(int deptId) {
        return deptMapper.modifyDeptInfoByDeptId(deptId);
    }

    @Override
    public Dept getDeptInfoById(int deptId) {
        return deptMapper.findDeptInfoById(deptId);
    }
}
